package com.zjuee.core.translation.factory;

import com.zjuee.core.translation.handledata.GetServiceStrategy;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 策略工厂
 */
@Component
public class ServiceStrategyFactory {
    /**
     * 服务实现后缀
     */
    private static final String CONTACT_SERVICE_SUFFIX = "ServiceStrategy";
    private static Map<String, GetServiceStrategy> ServiceStrategymap;

    private ApplicationContext applicationContext;

    public ServiceStrategyFactory(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
        init();
    }

    public static GetServiceStrategy getServiceStrategyImpl(String hotelCode) {
        return ServiceStrategymap.get(hotelCode);
    }

    private void init(){
        ServiceStrategymap = applicationContext.getBeansOfType(GetServiceStrategy.class);
    }
}
